package com.example.demo.servse;

import com.example.demo.domain.User;
import com.example.demo.mapper.StudentMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class student {
    public static void main(String[] args) throws IOException {
        StudentMapper mapper;
        InputStream resourceAsStream = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
        mapper= sqlSession.getMapper(StudentMapper.class);
        List<User> all = mapper.findAll();
        System.out.println(all);
    }
}
